﻿using AnlianCommon.API.Commands.Startofseasons;
using AnlianCommon.Common.Domains.BeginningManagement;
using AnlianCommon.Common.DTO;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Yitter.IdGenerator;

namespace AnlianCommon.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class StartofseasonController : ControllerBase
    {
        private readonly IMediator mediator;

        public StartofseasonController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 期初创建命令
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> CreateStartofseason(StartofseasonCreateCommand request, CancellationToken cancellationToken)
        {
            //单据号雪花ID
            request.Document = YitIdHelper.NextId().ToString();
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 公羊期初显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost] 
        public async Task<ResultPage<Startofseason>> CreateStartofseasonzero(StartofseasonSearchZeroCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 母羊期初显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultPage<Startofseason>> CreateStartofseason1(StartofseasonSearchOneCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 后裔期初显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost] 
       public async Task<ResultPage<Startofseason>> CreateStartofseason2(StartofseasonSearchTwoCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }

        /// <summary>
        /// 处理删除命令
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> DeleteStartofseason(StartofseasonDeleteCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
    }
}
